package com.trying.simpleioc.util;

import java.io.Closeable;
import java.io.IOException;

import org.apache.log4j.Logger;

/**
 * closeable关闭工具
 * @author dimi
 *
 */
public class CloseableUtil {
	private static final Logger log=Logger.getLogger(ReflectionUtil.class);

	private CloseableUtil(){}
	
	/**
	 * 关闭一个或者多个closeable对象
	 * @param closeables
	 */
	public static void closeMore(Closeable ... closeables){
		for(Closeable clo:closeables){
			close(clo);
		}
	}

	/**
	 *关闭一个closeable对象
	 */
	public static void close(Closeable closeable){
		if(closeable==null)return;
		
		try {
			closeable.close();
		} catch (IOException e) {
			//nothing to do.
			log.error(e);
		}
	}
	
}
